﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Space_Conquest
{

    /// <summary>
    /// Represents an event in the game (Motion(), button press, mouse click, etc)
    /// Serialized and sent between Server / Clients in multiplayer game
    /// </summary>
    [Serializable]
    abstract class GameEvent
    {
        public int PlayerID;
    }
    
    /// <summary>
    /// A motion tick
    /// </summary>
    [Serializable]
    class MotionEvent : GameEvent
    {

        public MotionEvent()
        {
            // Motion not caused by a player
            PlayerID = -1;
        }

    }

    /// <summary>
    /// Mouse button pressed down
    /// </summary>
    [Serializable]
    class MouseDownEvent : GameEvent
    {

        public MouseButtons Button;
        public int X;
        public int Y;

        public MouseDownEvent(Player player, MouseButtons button, int x, int y)
        {
            PlayerID = player.ID;
            Button = button;
            X = x;
            Y = y;
        }

    }

    /// <summary>
    /// Mouse button let up
    /// </summary>
    [Serializable]
    class MouseUpEvent : GameEvent
    {

        public MouseButtons Button;
        public int X;
        public int Y;

        public MouseUpEvent(Player player, MouseButtons button, int x, int y)
        {
            PlayerID = player.ID;
            Button = button;
            X = x;
            Y = y;
        }

    }

    /// <summary>
    /// Key pressed down
    /// </summary>
    [Serializable]
    class KeyDownEvent : GameEvent
    {

        public Keys Key;
        public bool Shift;

        public KeyDownEvent(Player player, Keys key, bool shift)
        {

            PlayerID = player.ID;
            Key = key;
            Shift = shift;

        }

    }

    /// <summary>
    /// Key let up
    /// </summary>
    [Serializable]
    class KeyUpEvent : GameEvent
    {

        public Keys Key;
        public bool Shift;

        public KeyUpEvent(Player player, Keys key, bool shift)
        {

            PlayerID = player.ID;
            Key = key;
            Shift = shift;

        }

    }

    /// <summary>
    /// Send a chat message
    /// </summary>
    [Serializable]
    class ChatEvent : GameEvent
    {

        public string ChatMessage;

        public ChatEvent(Player player, string chatMessage)
        {

            PlayerID = player.ID;
            ChatMessage = chatMessage;

        }

    }

}
